//2009/08/26 18:06:21
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class MonotoneSequence
{
public:
    int longestMonotoneSequence(vector <int> seq)
    {
		int N = seq.size();
		vector<int> v1(N, 0);
		vector<int> v2(N, 0);
		v1[0] = 1;
		v2[0] = 1;
		int mmax1 = 1;
		int mmax2 = 1;
		for(int i=1; i<N; i++)
		{
			if(seq[i] > seq[i-1]) v1[i] += v1[i-1] + 1;
			else v1[i] = 1;
			mmax1 = max(v1[i], mmax1);
		}
		for(int i=1; i<N; i++)
		{
			if(seq[i] < seq[i-1]) v2[i] += v2[i-1] + 1;
			else v2[i] = 1;
			mmax2 = max(v2[i], mmax2); 
		}
		return max(mmax1, mmax2);
    }
};
